package com.example.demo.day.easyExcel.primary.day1.pro.service.serviceImpl;

import com.alibaba.excel.EasyExcel;
import com.example.demo.day.easyExcel.primary.day1.pro.entity.EduSubject;
import com.example.demo.day.easyExcel.primary.day1.pro.entity.SubjectData;
import com.example.demo.day.easyExcel.primary.day1.pro.listener.SubjectExcelListener;
import com.example.demo.day.easyExcel.primary.day1.pro.mapper.EduSubjectMapper;
import com.example.demo.day.easyExcel.primary.day1.pro.service.EduSubjectService;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;

public class EduSubjectServiceImpl extends ServiceImpl<EduSubjectMapper,EduSubject> implements EduSubjectService {

    @Override
    public void saveSubject(MultipartFile file, EduSubjectService subjectService) {
        InputStream in = null;
        try {
            in = file.getInputStream();
            EasyExcel.read(in, SubjectData.class, new SubjectExcelListener(subjectService)).sheet().doRead();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
